<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<select id='xuanze'>
			<option>选择大小</option>
			<option>大</option>
			<option>小</option>
		</select>
		<div id="div1" style="width: 111px; height: 111px;">
			<img src="img/11.jpg" id="img"/>
		</div>
		<input type="button" name="" id="" value="开始" onclick="qiehua()" />
	</body>
	<script type="text/javascript">
		function qiehua(){
			var sel = document.getElementById('xuanze').value;
			console.log(document.getElementById('xuanze').value);
			if(sel=="选择大小"){
				alert('请选择大小');
			}else{
				var img = document.getElementById('img')
				//每隔一段时间跳动一次
				var time=0;
				var set = setInterval(function(){
					var num=shu();
					if(time>=10){
						clearInterval(set)
						if(sel=='大'){
							if(num>=14){
								alert('恭喜你，猜对了');
								console.log('值1:'+num);
							}
							else{
								alert('抱歉，猜错了')
								console.log('值2:'+num);
							}
						}
						else{
							if(num<14){
								alert('恭喜你，猜对了');
								console.log('值3:'+num);
							}
							else{
								alert('抱歉，猜错了')
								console.log('值4:'+num);
							}
						}
					}
					img.src='img/'+num+'.jpg';
					time++;
				},1000)
				
		    }
		}
		function shu(){
			var ran=Math.floor(Math.random()*6)+11;
			//var ran2=Math.floor(Math.random()*6)+11;
			console.log(ran);
			//console.log(ran2);
			return ran;
			//return ran2;
		}
		
			
	</script>
</html>
